import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import '../res/listData.dart';
class ChatPage extends StatefulWidget {
  const ChatPage({Key? key}) : super(key: key);
  @override
  _ChatPageState createState() => _ChatPageState();
}
class _ChatPageState extends State<ChatPage> {
  doNothing() {}
  List <Widget> _getData(){
    var tempList =listData.map((Value){
      return
         InkWell(
                child: Slidable(
                    key: const ValueKey(0),
                    // ),
                    //  右滑动
                    endActionPane: ActionPane(
                      motion: const ScrollMotion(),
                      // dismissible: DismissiblePane(onDismissed: () {}),
                      children: [
                        Container(
                          margin: const EdgeInsets.only(left: 10.0),
                          width: 45.0,
                          height: 45.0,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(23.0),
                              color: const Color.fromRGBO(232, 232, 232, 1.0),
                            boxShadow: const[BoxShadow(color: Color.fromRGBO(
                                0, 0, 0, 1.0),blurRadius: .5)]

                          ),
                          // child: SlidableAction(
                          //   flex: 1,
                          //   onPressed: doNothing(),
                          //   backgroundColor: const Color(0xFF7BC043),
                          //   foregroundColor: Colors.white,
                          //   icon: Icons.arrow_upward,
                          //   label: '置顶',
                          // ),
                         child: InkWell(
                           onTap: (){
                             print('置顶');
                           },
                           child:Column(
                             children: const [
                              Icon(Icons.ac_unit),
                               Text('置顶'),
                             ],
                           ),
                         ),
                        ),
                        //   SlidableAction(
                        //   // An action can be bigger than the others.
                        //   flex: 1,
                        //   onPressed: doNothing(),
                        //   backgroundColor: const Color.fromRGBO(255, 0, 0, 1.0),
                        //   foregroundColor: Colors.white,
                        //   icon: Icons.archive,
                        //   label: '删除',
                        // ),

                      ],

                    ),
                    child: Column(children: [
                      Stack(children: [
                        Container(
                          margin: const EdgeInsets.only(top: 7.0,bottom: 7.0,left: 10.0,right: 10.0),
                            height: 55.0,
                            decoration: BoxDecoration(
                                boxShadow: const [BoxShadow(color: Color.fromRGBO(
                                    219, 219, 219, 1.0), blurRadius:3.0,)],
                                color: Colors.white, borderRadius: BorderRadius.circular(10.0)),
                            child: ListTile(
                              onTap: () {
                                print('点击了图层le');
                              },
                              trailing: Container(
                                margin:
                                const EdgeInsets.only(bottom: 40, right: 10.0),
                                child:  Text(Value['time'],
                                  style: const TextStyle(
                                    fontSize: 12.0,
                                      color: Color.fromRGBO(170, 170, 170, 1.0)),
                                ),
                              ),
                              leading: Container(
                                margin: const EdgeInsets.only(bottom: 10.0),
                                width: 50.0,
                                height: 50.0,
                                decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(25.0),
                                    color: Colors.lightBlue,
                                    image:  DecorationImage(
                                        image:NetworkImage (Value['imageUrl']))),
                              ),
                              title: Container(
                                margin: const EdgeInsets.only(),
                                child:Text(  Value['name'],   style: const TextStyle(fontSize: 16.0),)
                              ),
                              subtitle:Container(
                                margin: const EdgeInsets.only(bottom: 20.0),
                                child:  Text(Value['news'],style: const TextStyle(fontSize: 12.0),),
                              )
                            )
                        ),
                        Positioned(
                            left: 53.0,
                            top: 11.0,
                            child: Container(
                              padding: const EdgeInsets.only(left: 3.0,right: 3.0),
                              height: 14.0,
                              decoration: BoxDecoration(
                                  color: Colors.red,
                                  borderRadius: BorderRadius.circular(7.0)
                              ),
                              child: Align(
                                child: Text(Value['quantity'],style: const TextStyle(color: Colors.white),),
                              ),
                            )
                        )
                      ]
                      )
                    ]
                    )
                )
            );
    });
    return tempList.toList();
  }
  @override
  Widget build(BuildContext context) {
    return  Container(
      margin: const EdgeInsets.only(bottom: 20.0),
      child: Column(
        children: _getData(),
      ),
    );
  }
}

